package com.blb.kafka_producer.controller;

import com.blb.kafka_producer.config.KafkaConfig;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class KafkaController {

    @Resource
    private KafkaTemplate<String,String> kafkaTemplate;

    @RequestMapping("sendMessage")
    public String sendMessage(String message){
        kafkaTemplate.send(KafkaConfig.TOPIC,message);
        return "send:" + message;
    }
}
